package fr.webviewer.data;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Point;

/**
 * 
 * @author Anthony
 *
 */
public class RoadEntry implements Comparable<RoadEntry> {
	
	/**
	 * The road entry label, typically it's the number of the entry
	 */
	private String label;
	
	/**
	 * The position of the entry in the image
	 */
	private Point position;
	
	/**
	 * 
	 */
	private List<RoadEntry> subEntries;

	public RoadEntry(String label){
		this.label = label;
		subEntries = new ArrayList<RoadEntry>();
	}
	
	public RoadEntry(String label, Point position){
		this(label);
		this.setPosition(position);
	}
	
	public void add(RoadEntry entry){
		subEntries.add(entry);
	}
	
	public List<RoadEntry> getSubEntries(){
		return subEntries;
	}
	
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public void setPosition(Point position) {
		this.position = position;
	}

	public Point getPosition() {
		return position;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((label == null) ? 0 : label.hashCode());
		result = prime * result
				+ ((position == null) ? 0 : position.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RoadEntry other = (RoadEntry) obj;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		if (position == null) {
			if (other.position != null)
				return false;
		} else if (!position.equals(other.position))
			return false;
		return true;
	}

	public int compareTo(RoadEntry arg0) {
		return label.compareTo(arg0.label);
	}

	public void setChildren(List<RoadEntry> children) {
		this.subEntries = children;
	}

	public List<RoadEntry> getChildren() {
		return subEntries;
	}

	

}
